home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / uudecodeconf.thor < prev    next >
Text File  |  1998-05-24  |  3KB  |  150 lines

  1. /*
  2.  * $VER: UUDecodeConf.thor 4.2 (1.9.95)
  3.  *
  4.  * Decodes all uuencoded files in a conference.
  5.  *
  6.  * Version 4.2 changed by Troels to use Rexx/UUDecode.thor for
  7.  * decoding, instead of being hardcoded to use uuOut.
  8.  *
  9.  */
  10.  
  11. /* trace results */
  12. options results
  13.  
  14.     MDB_DELETED       =  5   /* Message is deleted. */
  15.  
  16. p = ' ' || address() || ' ' || show('P',,)
  17. thorport = pos(' THOR.',p)
  18.  
  19. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  20. else
  21. do
  22.     say 'No THOR port found!'
  23.     exit 10
  24. end
  25.  
  26. if ~show('p', 'BBSREAD') then do
  27.     address command
  28.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  29.         "WaitForPort BBSREAD"
  30. end
  31.  
  32. address BBSREAD
  33. GETGLOBALDATA GLOBALDATA
  34. if(rc ~= 0) then
  35. do
  36.     address(thorport)
  37.     REQUESTNOTIFY TEXT '"GETGLOBALDATA: ' || BBSREAD.LASTERROR || '"' BT '"_Ok"'
  38.     exit
  39. end
  40.  
  41. if GLOBALDATA.TMPDIR == '' then tmpfile = 'T:tfil1'
  42. else
  43. do
  44.     if ~(right(GLOBALDATA.TMPDIR,1) = ':' | right(GLOBALDATA.TMPDIR,1) = '/') then tmpfile = GLOBALDATA.TMPDIR || '/tfil1'
  45.     else tmpfile = GLOBALDATA.TMPDIR || 'tfil1'
  46. end
  47.  
  48. if exists(tmpfile) then address command 'delete >nil:' tmpfile
  49.  
  50. address(thorport)
  51. CURRENTSYSTEM stem CURRENT
  52. if(rc ~= 0) then 
  53. do
  54.     REQUESTNOTIFY TEXT '"CURRENTSYSTEM: ' || THOR.LASTERROR || '"' BT '"_Ok"'
  55.     exit
  56. end
  57.  
  58. if CURRENT.CONFNAME == "" then
  59. do
  60.     REQUESTNOTIFY TEXT '"No Active Conference"' BT '"_Ok"'
  61.     exit
  62. end
  63.  
  64.  
  65. GETMESSAGEARRAY CONF '"'CURRENT.CONFNAME'"' STEM ARRAY
  66. if(rc ~= 0) then 
  67. do
  68.     REQUESTNOTIFY TEXT '"GETMESSAGEARRAY: ' || THOR.LASTERROR || '"' BT '"_Ok"'
  69.     exit
  70. end
  71.  
  72. if ARRAY.COUNT == 0 then
  73. if(rc ~= 0) then 
  74. do
  75.     REQUESTNOTIFY TEXT '"No messages to process"' BT '"_Ok"'
  76.     exit
  77. end
  78.  
  79. mcnt = 0
  80.  
  81. drop MSGLIST.
  82.  
  83. address BBSREAD
  84.  
  85. do n = 1 to ARRAY.COUNT
  86.     READBRMESSAGE '"'||CURRENT.BBSNAME||'"' '"'||CURRENT.CONFNAME||'"' ARRAY.n headstem MSGHEAD datastem MSGDATA
  87.     if(rc ~= 0) then
  88.     do
  89.         address(thorport)
  90.         REQUESTNOTIFY TEXT '"READBRMESSAGE: ' || BBSREAD.LASTERROR || '"' BT '"_Ok"'
  91.         exit
  92.     end
  93.  
  94.     if ~(bittst(MSGDATA.FLAGS, MDB_DELETED)) then
  95.     do
  96.         mcnt = mcnt + 1
  97.  
  98.         MSGLIST.mcnt = ARRAY.n
  99.         MSGLIST.mcnt.SUBJECT = MSGHEAD.SUBJECT
  100.     end
  101. end
  102.  
  103.  
  104.  
  105. address(thorport)
  106.  
  107. do m = 1 to mcnt
  108.  
  109.     writemsg = 0
  110.  
  111.     do n = 1 to mcnt
  112.         if MSGLIST.n > 0 then
  113.         do
  114.             if writemsg > 0 then
  115.             do
  116.                 if MSGLIST.n.SUBJECT < MSGLIST.writemsg.SUBJECT then writemsg = n
  117.             end
  118.             else writemsg = n
  119.         end
  120.     end
  121.  
  122.     if writemsg > 0 then 
  123.     do
  124.         SAVEMESSAGE '"'||CURRENT.BBSNAME||'"' '"'||CURRENT.CONFNAME||'"' MSGLIST.writemsg NOHEADER NOANSI FILE tmpfile
  125.         if(rc ~= 0) then 
  126.         do 
  127.             REQUESTNOTIFY TEXT '"Not able to save current message."' BT '"_Ok"'
  128.             exit
  129.         end
  130.  
  131.         MSGLIST.writemsg = 0
  132.     end
  133. end
  134.  
  135. address command 'rx `GetEnv THOR/THORPath`Rexx/UUDecode.thor ' || tmpfile
  136.  
  137. address(thorport)
  138. if(rc ~= 0) then
  139. do
  140.     REQUESTNOTIFY TEXT '"'Error in uudecoding!'"' BT '"_Ok"'
  141. end
  142. else
  143. do
  144.     REQUESTNOTIFY TEXT '"'Done!'"' BT '"_Ok"'
  145. end
  146.  
  147. address command 'delete >nil:' tmpfile
  148.  
  149. exit
  150.